package com.mxw.account.controller;

import com.mxw.account.dto.AccountDTO;
import com.mxw.commons.restful.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;

/** @Description @Author RingKo @Date 2021/8/23 22:13 @Version 1.0 */
@Slf4j
@RestController
@Validated
public class ValidatorTestController {
  /** @Description: 参数校验测试接口 */
  @GetMapping("/account/validate/test/get")
  public Result<Void> validateTestGet(
      @NotBlank(message = "[账户名称]不能为空") @RequestParam String accountName,
      @Max(value = 20, message = "id不能超过20") @RequestParam Long id) {
    log.info(accountName);
    log.info(id.toString());
    return Result.respond();
  }

  /** @Description: 参数校验测试接口 */
  @PostMapping("/account/validate/test/get2")
  public Result<Void> validateTestGet2(@RequestBody @Valid AccountDTO accountDTO) {
    log.info(accountDTO.toString());
    return Result.respond();
  }
}
